Pandas with colspan

by: slevin.kelevra, 9 years ago


Hi!
Can you help me with this thing?

For example: From csv there are several fields called AAA, BBB1, BBB2, CCC1, CCC2, DDD1, DDD2 ..........

How to generate table that will look like this?

---------------------------------------------------------------------------------------------------------------------------
|          |                    BBB                 |             CCC                         |                   DDD                 |
| AAA  |-----------------------------------------------------------------------------------------------------------------|
|          | BBB1(data)   | BBB2(data)  |   CCC1(data) | CCC2(data) | DDD1(data) | DDD2(data) |
|--------------------------------------------------------------------------------------------------------------------------|

Thank you!



You must be logged in to post. Please login or register an account.



If you read in from a csv, you really should be able to just use df = read_csv('youcsv.csv').

Otherwise, not sure I follow your question.

-Harrison 9 years ago

You must be logged in to post. Please login or register an account.


This is a source csv file
AAA;BBB1;BBB2;CCC1;CCC2;DDD1;DDD2
Some data;Some data;Some data;Some data;Some data;Some data;Some data
Some data;Some data;Some data;Some data;Some data;Some data;Some data
Some data;Some data;Some data;Some data;Some data;Some data;Some data
Some data;Some data;Some data;Some data;Some data;Some data;Some data
Some data;Some data;Some data;Some data;Some data;Some data;Some data
Some data;Some data;Some data;Some data;Some data;Some data;Some data
Some data;Some data;Some data;Some data;Some data;Some data;Some data
Some data;Some data;Some data;Some data;Some data;Some data;Some data
Some data;Some data;Some data;Some data;Some data;Some data;Some data
Some data;Some data;Some data;Some data;Some data;Some data;Some data
Some data;Some data;Some data;Some data;Some data;Some data;Some data


In the end I want to make a table with the merge of certain columns (BBB1 and BBB2 into BBB, CCC1 and CCC2 into CCC, DDD1 and DDD2 into DDD), similar to "colspan" in HTML.


-slevin.kelevra 9 years ago
Last edited 9 years ago

You must be logged in to post. Please login or register an account.


Ah, I see. I really do not think Pandas will do this for you, unfortunately. Never seen something like that done at least.

-Harrison 9 years ago

You must be logged in to post. Please login or register an account.


Decided that the formation of the structure of the table.
Thank you :)

-slevin.kelevra 9 years ago

You must be logged in to post. Please login or register an account.